package com.example.baseutils.activity

import com.example.baseutils.activity.BaseActivity
import com.example.baseutils.net.NetListtenr
import com.example.baseutils.net.NetState
import com.example.baseutils.ui.ProgressDialog

abstract class BaseLoadActivity : BaseActivity(), NetListtenr {
    abstract fun onLoad()
    protected var onLineState=false
    protected var canOut=false
    protected var outTime=0L
    protected val dialog by lazy { ProgressDialog(this).init() }

    override fun onStart() {
        super.onStart()
        NetState.getInstance().addListtner(this)
    }

    override fun onStop() {
        super.onStop()
        NetState.getInstance().removeListtner(this)
    }

    override fun netState(state: Boolean) {
        onLineState=state
        if (state) onLoad()
    }

    override fun onBackPressed() {
        if(canOut)
            super.onBackPressed()
    }
}